The present invention relates to graphical image processing in a computer system and, in particular, to a particularly efficient mechanism for combining multiple separate bands of a graphical image into a single, multiple-band image buffer.
In most computer graphics display devices in use today, color graphical images to be displayed must be in a 4-band, interleaved format in which four contiguous data components specify four respective components of a single pixel of the graphical image. For example, in some such devices, four contiguous bytes of data specify alpha, blue, green and red components, respectively, of a single pixel. It is also common to store a graphical image as multiple, separate pixel arrays for each component of which the graphical image is composed. For example, a color graphical image may be stored in the memory of a computer as three separate buffers, the first buffer including red components of the pixels of the graphical image, the second buffer including) green components of the pixels of the graphical image, and the third buffer including blue components of the pixels of the graphical image.
To display a graphical image. each band of which is stored in a separate buffer, it is generally necessary to interleave the respective bands of the respective buffers into a single buffer of multiple-band pixels. For example. one such multiple-band pixel format is the general ABGR format which is generally alpha, blue, green, and red components of a single pixel stored as four respective, contiguous bytes. It is common for graphical images produced today to include approximately one million pixels. For example. common sizes for graphical images include rectangular grids of 1024-by-768 pixels or 1280-by-1024 pixels, i.e., 786,432 and 1,310,720 pixels, respectively. To produce from three separate buffers of respective bands of a graphical image a single buffer containing a four-band graphical image typically requires approximately three million read operations to read each component of each pixel from a respective one of the separate buffers and approximately four million write operations to store each band of each pixel in the single multiple-band buffer. Some conventional computer systems can store four (4) bytes in a single write operation and can therefore store approximately one million pixels in a single multiple-band buffer using, approximately one million write operations.
Because of the significant computer system resources required for such graphical image reformatting, a need persists in the industry for ever increasing) efficiency in conversion of graphical images from multiple buffers of respective single bands of the graphical image to a single buffer of multiple bands of the graphical image.
In accordance with the present invention. respective components of two or more multiple-band pixels are read from each of two or more single-band graphical image buffers, each of which includes components of a respective band of the multiple-band pixels. Two or more components of each band are stored in respective data words. For example, (i) two or more red components of two or more respective multiple-band pixels are read from a red buffer and are stored in a red data word, (ii) two or more green components of the two or more multiple-band pixels are read from a green buffer and are stored in a green data word. and (iii) two or more blue components of the two or more multiple-band pixels are read from a blue buffer and are stored in a blue data word. Data words, which include two or more components corresponding to each of first and third bands of two or more multiple-band pixels. are merged to form an interleaved data word in which respective components of the merged data words are interleaved. For example, if the first and third bands of the multiple-band pixels are alpha and green bands, respectively, the interleaved data word includes a component representing the alpha band of a first multiple-band pixel followed by a component representing the green band of the first multiple-band pixel followed by a component representing the alpha band of a second multiple-band pixel followed by a component representing the green band of the second multiple-band pixel, and so on. Data words, which include two or more components corresponding to each of second and fourth bands of the two or more multiple-band pixels, are merged to form a second interleaved data word in which respective components of the merged data words are interleaved. For example, if the second and fourth bands of the multiple-band pixels are blue and red bands, respectively, the second interleaved data word includes components representing the following in sequence the blue band of the first multiple-band pixel, the red band of the first multiple-band pixel, the blue band of the second multiple-band pixel, the red band of the second multiple-band pixel, and so on.
The first-mentioned interleaved data word and the second interleaved data word are then merged to form a third interleaved data word in which respective components of the first and second interleaved data words are interleaved with one another. Continuing in the above illustrative example, the third interleaved data word includes components representing the following in sequence: the alpha band of the first multiple-band pixel, the blue band of the first multiple-band pixel, the green band of the first multiple-band pixel, the red band of the first multiple-band pixel, the alpha band of the second multiple-band pixel, the blue band of the second multiple-band pixel, the green band of the second multiple-band pixel, the red band of the second multiple-band pixel, and so on. Therefore, the third interleaved data word includes two or more multiple-band pixels in the alpha, blue, green, red format.
In one embodiment, a single read operation reads eight components from each of three buffers which correspond to red, green and blue bands, respectively, of a multiple-band graphical image. Of the eight components of each band read using(the single read operation, four components of each band are merged to form four multiple-band pixels simultaneously. A single merge operation merges eight components representing alpha and green bands of four multiple-band pixels, and a single merge operation merges eight components representing blue and red bands of the four multiple-band pixels. Two additional merge operations merge the merged data words to form four multiple-band pixels, each of which includes alpha, blue, green, and red components. Eight multiple-band pixels, each of which is four bytes in length, are written to a destination buffer in four write operations. Thus, to convert eight pixels from single-band format to multiple-band format, e.g., alpha, blue, green, and red format, requires three read operations, eight merge operations, and four write operations, i.e., a total of fifteen operations. Using prior art techniques, such format conversion of three components of each of eight pixels to eight multiple-band pixels typically requires eight read operations for each band, i.e., twenty-four read operations, and thirty-two write operations which total fifty-six operations. In addition, each component is typically moved individually into an interleaved, multiple-band format in a separate assignment operation. Thus, thirty-two assignment operations are required as well, bringing the total number of required operations to eighty-eight. As a result, the present invention represents a significant reduction of the required processing resources to convert single-band pixel components to multiple-band pixels over prior art techniques.